package com.pubinfo.passbook.api.controller.system;

import com.pubinfo.passbook.common.entity.TRequestLog;
import com.pubinfo.passbook.common.model.dto.system.SyncLogListParam;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.model.vo.base.MyPage;
import com.pubinfo.passbook.common.model.vo.log.LogListVo;
import com.pubinfo.passbook.common.service.master.TSyncLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "log")
@Api(tags = "请求日志管理")
@Slf4j
public class SyncLogController {
  @Autowired
  TSyncLogService logService;
  
  @PostMapping("list")
  @ApiOperation(value = "查询列表数据")
  public JsonResult<MyPage<LogListVo>> listInterfaceClassify(@RequestBody SyncLogListParam paramObj) {
    return JsonResult.success(new MyPage(logService.listTSyncLog(paramObj)));
  }
  
  @GetMapping("details/{logId}")
  @ApiOperation(value = "查询日志详情")
  public JsonResult<TRequestLog> details(@PathVariable("logId") String logId) {
    
    return JsonResult.success(logService.getById(logId));
  }
  
  @DeleteMapping("remove/{logId}")
  @ApiOperation(value = "删除一条日志")
  public JsonResult<Boolean> delete(@PathVariable("logId") String logId) {
    return JsonResult.success(logService.removeById(logId));
  }
  
  @PostMapping("removeBatch")
  @ApiOperation(value = "批量删除日志")
  public JsonResult<Boolean> delete(String[] logIds) {
    return JsonResult.success(logService.removeByIds(CollectionUtils.arrayToList(logIds)));
  }
}
